Completed
Pull Request — develop (#212)
by Xaver
29s
created

locationmarker.js ➔ define   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 36
rs 8.8571
nop 1

4 Functions

Rating   Name   Duplication   Size   Complexity  
A locationmarker.js ➔ ... ➔ L.CircleMarker.extend.setLatLng 0 5 1
A locationmarker.js ➔ ... ➔ L.CircleMarker.extend.initialize 0 10 1
A locationmarker.js ➔ ... ➔ L.CircleMarker.extend.onAdd 0 5 1
A locationmarker.js ➔ ... ➔ L.CircleMarker.extend.setAccuracy 0 3 1
1
define(['leaflet'], function (L) {
2
  'use strict';
3
4
  return L.CircleMarker.extend({
5
    outerCircle: config.locate.outerCircle,
6
    innerCircle: config.locate.innerCircle,
7
    accuracyCircle: config.locate.accuracyCircle,
8
9
    initialize: function (latlng) {
10
      this.accuracyCircle = L.circle(latlng, 0, this.accuracyCircle);
11
      this.outerCircle = L.circleMarker(latlng, this.outerCircle);
12
      L.CircleMarker.prototype.initialize.call(this, latlng, this.innerCircle);
13
14
      this.on('remove', function () {
15
        this._map.removeLayer(this.accuracyCircle);
16
        this._map.removeLayer(this.outerCircle);
17
      });
18
    },
19
20
    setLatLng: function (latlng) {
21
      this.accuracyCircle.setLatLng(latlng);
22
      this.outerCircle.setLatLng(latlng);
23
      L.CircleMarker.prototype.setLatLng.call(this, latlng);
24
    },
25
26
    setAccuracy: function (accuracy) {
27
      this.accuracyCircle.setRadius(accuracy);
28
    },
29
30
    onAdd: function (map) {
31
      this.accuracyCircle.addTo(map).bringToBack();
32
      this.outerCircle.addTo(map);
33
      L.CircleMarker.prototype.onAdd.call(this, map);
34
    }
35
  });
36
});
37